package br.com.android;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;
import android.widget.*;
import android.view.*;
import android.app.*;

public class appCompra extends Activity {
    /** Called when the activity is first created. */
    CheckBox chkarroz, chkleite, chkcarne, chkfeijao;
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        chkarroz = (CheckBox) findViewById(R.id.chkarroz);
        chkleite = (CheckBox) findViewById(R.id.chkleite);
        chkcarne = (CheckBox) findViewById(R.id.chkcarne);
        chkfeijao = (CheckBox) findViewById(R.id.chkfeijao);
        
        Button bttotal = (Button) findViewById(R.id.btotal);
        
        bttotal.setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
			double total = 0;
			if(chkarroz.isChecked())
				total += 2.69;
			if(chkleite.isChecked())
				total += 5.00;
			if(chkcarne.isChecked())
				total += 9.7;
			if(chkfeijao.isChecked())
				total += 2.30;
			
			AlertDialog.Builder dialogo = new AlertDialog.Builder(appCompra.this);
			dialogo.setTitle("AVISO");
			dialogo.setMessage("Valor Total da Compra : " + String.valueOf(total));
			dialogo.setNegativeButton("OK", null);
			dialogo.show();
				
			}
		});
    }
}